﻿// Copyright (C) Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Limited Public License (Ms-LPL).

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;

using Microsoft.VisualStudio.IntelliTrace;

namespace Microsoft.VisualStudio.Samples
{
	internal abstract class EventChainFormatter
	{
		protected EventChainFormatter(IntelliTraceProcess process)
		{
			Process = process;
		}

		protected IntelliTraceProcess Process { get; private set; }

        public virtual void FireEvents()
        {
            StreamChain eventChain = getStreamChain();
            EventToken eventToken = eventChain.FirstValidToken;
            while (eventToken != eventChain.AfterLastToken)
            {
                IntelliTraceEvent ev = eventChain.GetEvent(eventToken);

                // Find the specific formatter for this event and dump out the event.
                FireEvent(ev);

                // Advance to the next event in the chain.
                eventToken = eventChain.GetNextToken(eventToken);
            }

        }
        protected abstract StreamChain getStreamChain();

        protected abstract void FireEvent(IntelliTraceEvent ev);
	}
}
